package mysql

import (
	"gorm.io/gorm"
)

type Class struct {
	gorm.Model
	ClassName string `gorm:"type:varchar(30)" json:"class_name"`
	ClassNum  int64  `gorm:"type:int(10)" json:"class_num"`
	ClassTime string `gorm:"type:datetime" json:"class_time"`
}

func (c *Class) FindClasses(page, pagesize int) (class []*Class, err error) {
	var classes []*Class
	err = DB.Limit(page).Offset(pagesize).Order("class_num desc").Find(&classes).Error
	if err != nil {
		return nil, err
	}
	return classes, nil
}
